package com.jatosoft.poc.priceinquiry.core.dao.jpa;

import java.util.List;

import javax.persistence.Query;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.jatosoft.poc.priceinquiry.core.domain.Article;

public class GenericJPADao extends BaseJPADao {

	public void save(Article a) {
		if (log.isDebugEnabled())
			log.debug("save " + a);
		em.persist(a);
	}
	
	public Article get(String id){
		/*
		Query q = em.createQuery("select article from Article as article");
		List l = q.getResultList();
		l.toString();
		*/
		
		return em.find(	Article.class, KeyFactory.stringToKey(id));
		
	}
	
	public List query(String query){
		Query q = em.createQuery(query);
		List l = q.getResultList();
		return l;
	}
	
	public void delete(Object entity){
		em.remove(entity);
	}
}
